Skip to content

fix: draining strategy fetch#5449

Open
nugaon wants to merge 2 commits into
masterfrom
fix/draining-strategy-fetch
Open

fix: draining strategy fetch#5449
nugaon wants to merge 2 commits into
masterfrom
fix/draining-strategy-fetch

Conversation

@nugaon
Copy link
Copy Markdown
Member

@nugaon nugaon commented May 5, 2026

fixes: #5448

runStrategy uses defer cancel() with a for range c loop to drive chunk fetches. When the loop exits early (enough chunks fetched or too many failed), cancel() fires but goroutines already inside g.fetcher.Get continue running. These ghost goroutines from a failed DATA strategy mutate shared atomic counters g.failedCnt and g.fetchedCnt concurrently with the subsequent RACE strategy, corrupting its accounting and causing it to terminate prematurely with errStrategyFailed even when enough parity chunks are available. Additionally, for range c never terminates on its own since c is never closed — the function can only exit via early returns.

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

AI Disclosure

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
  • I possess the technical expertise to responsibly review the code generated in this PR.

@acud
Copy link
Copy Markdown
Contributor

acud commented May 5, 2026

@nugaon, @sbackend123 already has a fix for this here. can you please review that first?

@acud
Copy link
Copy Markdown
Contributor

acud commented May 27, 2026

@nugaon can we have a rebase please?

@nugaon nugaon force-pushed the fix/draining-strategy-fetch branch from 0709fae to dbe655b Compare May 28, 2026 10:44
var (
errStrategyNotAllowed = errors.New("strategy not allowed")
errStrategyFailed = errors.New("strategy failed")
errShouldNeverHappen = errors.New("should never happen")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a sort of defensive programming that suggests that the code does not do proper error handling. if one cannot reason about values that function calls return, you end up in this sort of situation. i am approving just because i trust that the scope of the change is known (but also because this package is completely unreadable to me)

@martinconic
Copy link
Copy Markdown
Contributor

Please add some description of what is done into this PR, more than just linking to the issue.

@nugaon
Copy link
Copy Markdown
Member Author

nugaon commented Jun 1, 2026

I copied the summary from the issue, but the issue has all the details... so why the PR description is required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

redundancy strategy fetch drain

3 participants